/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package commonClasses.Messages;

import commonClasses.*;
import commonClasses.commonInterfaces.MsgIntf;
import commonClasses.commonInterfaces.ProtocolIntf;

/**
 *
 * @author Pozytywny!
 */
public class EnterAuctionMsg extends Msg implements MsgIntf {

    private long _itemID = 678;

    public EnterAuctionMsg(ProtocolIntf protocolIntf, long itemID) {
        super(protocolIntf, MagicNumbers.ENTER_MSG_NR);
        _itemID = itemID;
    }

    public EnterAuctionMsg(ProtocolIntf protocolIntf) {
        super(protocolIntf, MagicNumbers.ENTER_MSG_NR);

    }

    public long getItemID() {
        return _itemID;
    }



    public void receive() throws Exception {
        long itemID = receiveUint();
        _itemID = itemID;
        Utils.clientReceived(_itemID);

        long priceValue = receiveUint();
        Utils.clientReceived(priceValue);

        String priceCurrency = String.valueOf(receiveCharArr(3));
        Utils.clientReceived(priceCurrency);

        int length = longToInt(receiveUint());
        Utils.clientReceived(length);

        String desc = String.valueOf(receiveCharArr(length));
        Utils.clientReceived(desc);

    }

    public void send() throws Exception {
        int mesgId[] = this.idToIntArr();
        sendIntArr(mesgId);

        int itemId[] = longToArr(_itemID);
        sendIntArr(itemId);

        int priceValue[] = longToArr(0);
        sendIntArr(priceValue);

        char priceCurrent[] = stringToCharArr("---");
        sendCharArr(priceCurrent);

        int length[] = longToArr(0);
        sendIntArr(length);
    }
}
